package com.icim.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import com.icim.entity.Ret_box;

@Repository
public class RetBoxDao {
    @Resource
    private JdbcTemplate icimJdbcTemplate;

    public List<Ret_box> getBoxList(String palletId) {
        String sql = "SELECT * FROM RET_BOX WHERE PALLET_ID_FK = ?";
        return icimJdbcTemplate.query(sql, new Object[] { palletId }, new RowMapper<Ret_box>() {

            @Override
            public Ret_box mapRow(ResultSet rs, int rowNum) throws SQLException {
                Ret_box retBox = new Ret_box();
                retBox.setBox_id(rs.getString("BOX_ID"));
                retBox.setPrd_qty(rs.getInt("PRD_QTY"));
                retBox.setStd_qty(rs.getInt("STD_QTY"));
                retBox.setMdl_id(rs.getString("MDL_ID_FK"));
                retBox.setShip_pallet_name(rs.getString("EXT_11"));
                retBox.setShip_box_id(rs.getString("SHIP_BOX_ID"));
                retBox.setMtrl_prod_id(rs.getString("MTRL_PROD_ID_FK"));
                retBox.setLot_id_fk(rs.getString("LOT_ID_FK"));
                retBox.setBox_cate(rs.getString("BOX_CATE"));
                retBox.setWo_id_fk(rs.getString("WO_ID_FK"));
                retBox.setDestination(rs.getString("EXT_12"));
                return retBox;
            }
        });

    }
}
